package com.wy.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.wy.system.domain.SysInform;
import com.wy.system.service.ISysInformService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wy.common.annotation.Log;
import com.wy.common.core.controller.BaseController;
import com.wy.common.core.domain.AjaxResult;
import com.wy.common.enums.BusinessType;
import com.wy.common.utils.poi.ExcelUtil;
import com.wy.common.core.page.TableDataInfo;

/**
 * 上报信息Controller
 * 
 * @author ruoyi
 * @date 2023-03-07
 */
@RestController
@RequestMapping("/system/inform")
public class SysInformController extends BaseController
{
    @Autowired
    private ISysInformService sysInformService;

    /**
     * 查询上报信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:inform:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysInform sysInform)
    {
        startPage();
        List<SysInform> list = sysInformService.selectSysInformList(sysInform);
        return getDataTable(list);
    }

    /**
     * 导出上报信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:inform:export')")
    @Log(title = "上报信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysInform sysInform)
    {
        List<SysInform> list = sysInformService.selectSysInformList(sysInform);
        ExcelUtil<SysInform> util = new ExcelUtil<SysInform>(SysInform.class);
        util.exportExcel(response, list, "上报信息数据");
    }

    /**
     * 获取上报信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:inform:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysInformService.selectSysInformById(id));
    }

    /**
     * 新增上报信息
     */
    @PreAuthorize("@ss.hasPermi('system:inform:add')")
    @Log(title = "上报信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysInform sysInform)
    {
        return toAjax(sysInformService.insertSysInform(sysInform));
    }

    /**
     * 修改上报信息
     */
    @PreAuthorize("@ss.hasPermi('system:inform:edit')")
    @Log(title = "上报信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysInform sysInform)
    {
        return toAjax(sysInformService.updateSysInform(sysInform));
    }

    /**
     * 删除上报信息
     */
    @PreAuthorize("@ss.hasPermi('system:inform:remove')")
    @Log(title = "上报信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysInformService.deleteSysInformByIds(ids));
    }
}
